package practice;

import java.util.ArrayList;
import java.util.List;

public class JosephRing {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            list.add(i);
        }
        int count = 0;
        while (list.size() > 0){
            count = count + 3;
            count = count % (list.size())-1;
        if (count < 0){
            System.out.println(list.get(list.size()-1));
            list.remove(list.size()-1);
            count = 0;
        }else {
            System.out.println(list.get(count));
            list.remove(count);
        }
        }
        }
    }

